/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
  const { currentUser } = initialState ?? {};
  console.log(currentUser);
  return {
    canAdmin: true,
    // 此处返回的布尔值表示用户是否能使用此功能
    canUse: () => {
      if (currentUser?.role?.name === 'admin') {
        return true;
      }

      return false;
    },
  };
}
